package git.soulbgm.mapreduce.mapJoin;

import git.soulbgm.mapreduce.utils.DriverUtil;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.NullWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Job;

import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;

/**
 * @author SoulBGM
 * @date 2021/12/4 19:37
 */
public class MapJoinDriver {

    public static void main(String[] args) throws InterruptedException, IOException, ClassNotFoundException, URISyntaxException {
        Job job = DriverUtil.createJob(MapJoinDriver.class, MapJoinMapper.class, null,
                Text.class, NullWritable.class, Text.class, NullWritable.class,
                new Path(args[0]), new Path(args[1]));

        // 加载缓存数据
        job.addCacheFile(new URI("file:///D:/home/input_mapjoin/pd.txt"));
        // Map端Join的逻辑不需要Reduce阶段，设置reduceTask数量为0
        job.setNumReduceTasks(0);

        // 7 提交job
        boolean result = job.waitForCompletion(true);
        System.exit(result ? 0 : 1);
    }

}
